<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- H5规定自定义属性data-开头作为属性名并且赋值 -->
    <div getTime="20" data-index="2">

    </div>

    <script>
        var div = document.querySelector('div');
        // console.log(div.className);
        console.log(div.getTime);//undefined
        console.log(div.getAttribute('getTime'));
        console.log(div.getAttribute('data-index'));
        div.setAttribute('data-time', '22');

        //H5新增
        console.log('--------------');
        //dataset是一个集合，存放了所有以data开头的自定义属性
        console.log(div.dataset);
        console.log(div.dataset.index);
    </script>
</body>

</html>